import Vue from 'vue'
import VueRouter from 'vue-router'
import ArtistsIndex from '../pages/Artists'
import HomeIndex from '../pages/Home'
import MineIndex from '../pages/Mine'
import SearchIndex from '../pages/Search'
import SongListIndex from '../pages/SongList'
import TopIndex from '../pages/Top'
import SongPlayerIndex from '../pages/Player'

Vue.use(VueRouter)

export default function () {
  const router = new VueRouter({
    mode: 'history',
    linkActiveClass: 'active',
    routes: [
      {
        path: '/',
        name: 'HomeIndex',
        component:HomeIndex,
        alias: '/home-index'
      },
      {
        path: '/artists-index',
        name: 'ArtistsIndex',
        component: ArtistsIndex
      },
      {
        path: '/mine-index',
        name: 'MineIndex',
        component: MineIndex
      },
      {
        path: '/search-index',
        name: 'SearchIndex',
        component: SearchIndex
      },
      {
        path: '/song-list-index',
        name: 'SongListIndex',
        component: SongListIndex
      },
      {
        path: '/top-index',
        name: 'TopIndex',
        component: TopIndex
      },
      {
        path: '/song-player-index/:songId',
        name: 'SongPlayerIndex',
        component: SongPlayerIndex
      }
    ]
  })

  router.beforeEach((to, from, next) => {
    // console.log(to)
    next()
  })

  return router
}
